﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using KendoMvcUI.Core;
using KendoMvcUI.Common;
using System.Web.Mvc;

namespace KendoMvcUI.UI
{
    public class ToolBar:KendoUIBase
    {
        public ToolBar(KendoUIControlSettings settings,ViewContext context,IViewDataContainer container)
            :base(settings,context,container)
        { }
        public override string RenderHtml()
        {
            return "<div id=\"{0}\"></div>".Formator(Settings.Id);
        }
    }
    public class ToolBarSettings : KendoUIControlSettings
    {
        public ToolBarSettings()
            : base("kendoToolBar")
        { }
        public bool? Resizable { get; set; }
        public Action<List<ToolBarItemSettings>> Items { get; set; }

        #region 事件
        public string On_Click { get; set; }
        public string On_Close { get; set; }
        public string On_Open { get; set; }
        public string On_Toggle { get; set; }
        public string On_OverflowClose { get; set; }
        public string On_OverflowOpen { get; set; }
        #endregion

        public override string ToJsSettings()
        {
            var js= base.ToJsSettings();
            if(Items!=null)
            {
                string itemStr="";
                List<ToolBarItemSettings> items = new List<ToolBarItemSettings>();
                Items(items);
                items.ForEach(i =>
                {
                    itemStr += "{" + i.ToJsSettings() + "},";
                });
                js += "items:[{0}],".Formator(itemStr.TrimEnd(','));
            }

            return js.TrimEnd(',');
        }
    }
}
